{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "Copyright(c) 2025 NVIDIA Corporation. All rights reserved.\n",
    "\n",
    "NVIDIA Corporation and its licensors retain all intellectual property\n",
    "and proprietary rights in and to this software, related documentation\n",
    "and any modifications thereto.Any use, reproduction, disclosure or\n",
    "distribution of this software and related documentation without an express\n",
    "license agreement from NVIDIA Corporation is strictly prohibited.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Setup Pre-requisites\n",
    "\n",
    "This notebook provides step-by-step instructions for setting up the prerequsites for doing the hands-on customizations for the Digital Human Agent. The notebook assumes that it is run on a machine that has the kubernetes context set to the system where the Tokkio deployment is running. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Ensure that the Digitial Human application is running. \n",
    "Use the following command to check if all pods are in a running state. \n",
    "\n",
    "Note: You will need to select the python environment to run the notebooks for the first time. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NAME                                                       READY   STATUS    RESTARTS   AGE\n",
      "a2f-a2f-deployment-bb9896cd6-zx8tx                         1/1     Running   0          5h37m\n",
      "ace-configurator-deployment-5ff97d9548-7t6tl               1/1     Running   0          5h37m\n",
      "ace-controller-ace-controller-deployment-0                 1/1     Running   0          5h37m\n",
      "ace-controller-sdr-envoy-sdr-deployment-7f48564bb9-dppsc   4/4     Running   0          3m37s\n",
      "anim-graph-sdr-envoy-sdr-deployment-59c6c98656-s4ftq       4/4     Running   0          5h37m\n",
      "ia-animation-graph-microservice-deployment-0               1/1     Running   0          5h37m\n",
      "ia-unreal-renderer-microservice-deployment-0               3/3     Running   0          5h37m\n",
      "redis-redis-757cfc4b4b-vz9qb                               1/1     Running   0          5h37m\n",
      "redis-timeseries-redis-timeseries-5d854596c-bpfll          1/1     Running   0          5h37m\n",
      "riva-speech-5b8597d5ff-266vb                               1/1     Running   0          5h37m\n",
      "tokkio-ingress-mgr-deployment-64d97746c6-mxmvw             2/2     Running   0          5h37m\n",
      "tokkio-ui-deployment-7b5dfcf56d-mcc48                      1/1     Running   0          3m37s\n",
      "triton0-5cb884f465-vzzbv                                   1/1     Running   0          5h37m\n",
      "ue-renderer-sdr-envoy-sdr-deployment-65867b9ffb-896ln      4/4     Running   0          5h37m\n",
      "vms-vms-6f8b4dc444-x4dbb                                   1/1     Running   0          5h37m\n"
     ]
    }
   ],
   "source": [
    "!kubectl get po -n app"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Launch the ACE Configurator in VSCode\n",
    "1. In VSCode, open the **Command Palette** . You can use the shortcut `Ctrl + Shift + P` to launch it.\n",
    "2. Search for **Explorer: Focus on ACE Configuration View** and select it."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![ACE Configurator](pictures/ace_configurator.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Set the Configuator API URL\n",
    "\n",
    "Run the script below to obtain the URL needed for the configurator API. Note that the configurator API URL is also output at the end of successful deployment of the Tokkio application by the deployment scripts. For Tokkio running on CSP instances, use https instead of http for the URL "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Configurator API URL: 10.176.10.252:30180. Use http:// or https:// prefix, depending on Baremetal or CSP installation respectively.\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "# Extract the server IP address from the Kubernetes config\n",
    "server_ip=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}' | sed 's|http[s]*://||' | cut -d':' -f1)\n",
    "\n",
    "# Ensure a valid server IP was found\n",
    "if [[ -z \"$server_ip\" ]]; then\n",
    "  echo \"Error: Unable to extract server IP from Kubernetes config.\"\n",
    "  exit 1\n",
    "fi\n",
    "\n",
    "# Append port 30180 to the extracted IP\n",
    "configurator_url=\"${server_ip}:30180\"\n",
    "\n",
    "# Output the result\n",
    "echo \"Configurator API URL: $configurator_url. Use http:// or https:// prefix, depending on Baremetal or CSP installation respectively.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Note down the Configurator API URL from the step above. \n",
    "\n",
    "* In the ACE Configurator view, click **Set Configurator API URL**.\n",
    "\n",
    "* Input the Configurator API URL you noted above.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Download the ACE Controller Configuration\n",
    "In the ACE Configurator view, click on **Download** to download the ACE Controller Configuration as shown below. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![ACE Configurator](pictures/ace_configurator_download_config.png)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
